package com.springboot.cropsboot.controller;


import com.springboot.cropsboot.entity.Admin;
import com.springboot.cropsboot.entity.Nongzw;
import com.springboot.cropsboot.qpage.QPage;
import com.springboot.cropsboot.service.INongzwService;
import com.springboot.cropsboot.util.ResultView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2023-12-02
 */
@RestController
@RequestMapping("/api/admin/nongzw")
public class NongzwController {

    @Autowired
    private INongzwService nongzwService;

    /**
     * 列表分页
     * @param obj
     * @return
     */
    @GetMapping("/getPageList")
    public ResultView getPageList(QPage qPage, Nongzw obj) {
        return this.nongzwService.getPageList(qPage,obj);
    }


    /**
     * 新增
     * @param obj
     * @return
     */
    @PostMapping("/saveObj")
    public ResultView saveObj(Nongzw obj) {
        obj.setCtime(new Date());
        return this.nongzwService.saveObj(obj);
    }

    /**
     * 获取当前ID信息
     * @param obj
     * @return
     */
    @GetMapping("/getId")
    public ResultView getAgentId(Nongzw obj) {
        Nongzw nongzw=this.nongzwService.getById(obj.getId());
        return ResultView.ok(nongzw);
    }

    /**
     * 修改
     * @param obj
     * @return
     */
    @PostMapping("/updateObj")
    public ResultView updateObj(Nongzw obj) {
        return this.nongzwService.updateObj(obj);
    }


    /**
     * 删除
     * @param obj
     * @return
     */
    @PostMapping("/deleteObj")
    public ResultView deleteObj(Nongzw obj) {
        return this.nongzwService.deleteObj(obj);
    }


}
